<template>
	<div style="position: relative;height: 100%;">
		<div v-if="teacherSettingHidden" style="width: 100%;height: 100%;background-color: rgba(247,247,247,0.8);position: absolute;top: 20px;z-index: 999;"></div>
		<div style="width: 100%;height: 20px;background-color: #ebedf0;"></div>
		<!--教师任职-->
		<div style="padding: 20px;">
			<Row >
		        <Col span="24" style="text-align: left;margin-top:15px;">
		        	<span>任职：</span>
		        	<RadioGroup  v-model="holdPostSelect" type="button" @on-change="holdPostChange">
		        		<Radio v-for="item in holdPostList" :key="item.value" :label="item.value">{{item.label}}</Radio>
				    </RadioGroup>
		        </Col>
		    </Row>
		    <Row v-if="isSubjectLeaderTypeList">
		        <Col span="24" style="text-align: left;margin-top:15px;">
		        	<span>级别：</span>
		        	<RadioGroup  v-model="subjectLeaderTypeSelect" type="button" @on-change="subjectLeaderTypeChange">
		        		<Radio v-for="item in subjectLeaderTypeList" :key="item.value" :label="item.value">{{item.label}}</Radio>
				    </RadioGroup>
		        </Col>
		    </Row>
		    <Row v-if="isGradeList">
		        <Col span="24" style="text-align: left;margin-top:15px;">
		        	<span>年段：</span>
		        	<RadioGroup  v-model="gradeSelect" type="button" @on-change="gradeChange">
		        		<Radio v-for="item in gradeList" :key="item.value" :label="item.value">{{item.label}}</Radio>
				    </RadioGroup>
		        </Col>
		    </Row>
		    <Row v-if="isSubjectList">
		        <Col span="24" style="text-align: left;margin-top:15px;">
		        	<span>科目：</span>
		        	<RadioGroup  v-model="subjectSelect" type="button" @on-change="subjectChange">
		        		<Radio v-for="item in subjectList" :key="item.value" :label="item.value">{{item.label}}</Radio>
				    </RadioGroup>
		        </Col>
		    </Row>
		    <Row v-if="isDepartmentList">
		        <Col span="24" style="text-align: left;margin-top:15px;">
		        	<span>学部：</span>
		        	<RadioGroup  v-model="departmentSelect" type="button" @on-change="departmentChange">
		        		<Radio v-for="item in departmentList" :key="item.value" :label="item.value">{{item.label}}</Radio>
				    </RadioGroup>
		        </Col>
		    </Row>
		</div>
		
		<Row style="text-align: left;margin-top: 20px;">
			<Col span="12" style="text-align: left;">
    			<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
    			<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">教师任职列表</span>
    			<!--<span style="font-size: 12px;margin-left: 12px;color: rgba(102, 102, 102, 0.61);">均差=教师评价值  - 平均评价值</span>-->
    		</Col>
			<Col span="11" style="text-align: right;">
	        	<Input v-model="searchInfo" icon="ios-search" @on-click="searchTeacher" @on-enter="searchTeacher" placeholder="首字母/姓名/账号/手机号" style="width: 200px;cursor: pointer;"></Input>
	        	<Tooltip content="导出账号信息" theme="light" placement="top">
		        	<Button style="background-color: #4496fc;" size="small" :loading="loading" @click="exportexl">
		        		<span v-if="!loading"><img style="width: 20px;margin-top: 2px;" src="../../../../static/img/export.png" alt="" /></span>
				        <span v-else>加载中</span>
		        	</Button>
	        	</Tooltip>
	        	<Tooltip content="添加任职关系" theme="light" placement="top">
	        		<Button @click="addTeacherAndCancel"  type="success" size="small"><i class="iconfont alicon-add1"></i></Button>
	        	</Tooltip>
	        	<Tooltip content="编辑教师" theme="light" placement="top">
	        		<Button @click="editTeacher" type="warning" size="small"><i class="iconfont alicon-write"></i></Button>
	        	</Tooltip>
	        	<Tooltip content="删除任职关系" theme="light" placement="top">
	        		<Button @click="delteacher" type="error" size="small"><i class="iconfont alicon-delete"></i></Button>
	        	</Tooltip>
	       </Col>
		</Row >
		
	    <div style="padding: 10px 20px 20px 20px;">
	    	<div style="position: relative;">
			    <Table  border ref="selection" :columns="columns4" :data="data1" @on-selection-change="tableteacherselect"></Table>
		        <!--<Spin size="large" fix v-if="tableshow"></Spin>-->
	        </div>
	        <Page style="text-align: center;margin-top:15px;" :current="current" :total="recordCount" @on-change="pageChange"/>
	    </div>
	    
		
		
		
		
		<div v-if="teacherSettingHidden" style="z-index: 1000;float: left;width: 850px;height: 500px;background-color: white;border-radius: 15px;margin: auto;position: absolute;top: 200px;left: 0;right: 0;">
			<Row >
				<Col span="10" style="text-align: left;height:500px;border: 1px solid #e9eaec;padding: 10px;border-top-left-radius: 15px;border-bottom-left-radius: 15px;">
	    			<Row style="margin-bottom:15px;margin-top: 5px;line-height: 32px;">
	    				<Col span="4" style="text-align: center;">
							职称:
					    </Col>
			        	<Col span="20" style="text-align: center;">
				            <Select placeholder="请选择职称" v-model="settingroleselect" style="width:95%" @on-change="settingroleselectchange">
						        <Option v-for="item in settingrolelist" :value="item.value" :key="item.value">{{ item.label }}</Option>
						    </Select>
					    </Col>
					</Row>
					<div style="width:100%;height:1px;border-bottom: 1px solid #e9eaec;margin:10px 0px;"></div>
					<Row v-if="settingsubjectleadertypeselectshow" style="margin-bottom:10px;line-height: 32px;">
	    				<Col span="4" style="text-align: center;">
							级别:
					    </Col>
			        	<Col span="20" style="text-align: center;">
				            <Select placeholder="请选择等级" v-model="settingsubjectleadertypeselect" style="width:95%" @on-change="settingsubjectleadertypeselectchange">
						        <Option v-for="item in settingsubjectleadertypelist" :value="item.value" :key="item.value">{{ item.label }}</Option>
						    </Select>
					    </Col>
					</Row>
					<Row v-if="settinggradeselectshow" style="margin-bottom:10px;line-height: 32px;">
	    				<Col span="4" style="text-align: center;">
							年级:
					    </Col>
			        	<Col span="20" style="text-align: center;">
				            <Select placeholder="请选择年级" v-model="settinggradeselect" style="width:95%" @on-change="settinggradeselectchange">
						        <Option v-for="item in settinggradelist" :value="item.value" :key="item.value">{{ item.label }}</Option>
						    </Select>
					    </Col>
					</Row>
					<Row v-if="settingsubjectselectshow" style="margin-bottom:10px;line-height: 32px;">
	    				<Col span="4" style="text-align: center;">
							科目:
					    </Col>
			        	<Col span="20" style="text-align: center;">
				            <Select placeholder="请选择科目" v-model="settingsubjectselect" style="width:95%" @on-change="settingsubjectselectchange">
						        <Option v-for="item in settingsubjectlist" :value="item.value" :key="item.value">{{ item.label }}</Option>
						    </Select>
					    </Col>
					</Row>
					
					<Row v-if="settingdepartmentselectshow" style="margin-bottom:10px;line-height: 32px;">
	    				<Col span="4" style="text-align: center;">
							学部:
					    </Col>
			        	<Col span="20" style="text-align: center;">
				            <Select placeholder="请选择学部" v-model="settingdepartmentselect" style="width:95%" @on-change="settingdepartmentselectchange">
						        <Option v-for="item in settingdepartmentlist" :value="item.value" :key="item.value">{{ item.label }}</Option>
						    </Select>
					    </Col>
					</Row>
					<Row  style="line-height: 38px;">
	    				<Col span="6" style="text-align: center;">
							所选教师:
					    </Col>
					</Row>
					<Row  style="margin-bottom:10px;line-height: 38px;">
			        	<Col span="24" style="text-align: center;">
			        		<Row  >
					            <div v-for="item in teacherselect">
			        				<Col span="8"  style="text-align: center;margin-bottom:10px;">
					        			<div style="cursor:pointer;margin: 0 auto;width: 100px;height: 38px;line-height: 38px;border-radius: 5px;border: 1px solid #dddee1;background-color: #f7f7f7;">
					        				{{item.label}}
					        				<i style="font-size: 15px;" @click="choose" :label="item.label" :value="item.value" class="iconfont alicon-close_light"></i>
					        			</div>
					        		</Col>
			        			</div>
			        		</Row>
					    </Col>
					</Row>
					
					<Row  style="line-height: 38px;position: absolute;bottom: 10px;width: 100%;margin-left: -10px;">
						<div style="padding: 10px;width: 100%;">
							<div style="width:100%;height:1px;border-bottom: 1px solid #e9eaec;"></div>
						</div>
	    				<Col span="12" style="text-align: center;">
							<Button  @click="addTeacherAndCancel"  style="width: 105px;">取消</Button>
					    </Col>
			        	<Col span="12" style="text-align: center;">
				            <Button @click="saveteacher" type="primary" style="width: 105px;">保存当前老师</Button>
					    </Col>
					</Row>
	    		</Col>
				<Col span="14" style="text-align: left;height:500px;border: 1px solid #e9eaec;border-top-right-radius: 15px;border-bottom-right-radius: 15px;">
					<i style="font-size: 15px;position: absolute;cursor: pointer;right: 10px;top: 10px;" @click="addTeacherAndCancel" class="iconfont alicon-close_light"></i>
		        	<Row style="height: 33px;text-align: center;margin-top: 25px;">
		        		<Col span="6" style="text-align: right;line-height: 33px;">
		        			快速搜索：
		        		</Col>
		        		<Col span="18" style="text-align: left;">
		        			<Input v-model="settingSearchInfo" icon="ios-search" @on-click="settingSearchTeacher" @on-enter="settingSearchTeacher" placeholder="首字母/姓名/账号/手机号" style="width: 90%;cursor: pointer;"></Input>
		        		</Col>
	        		</Row >
	        		<!--<Row style="height: 60px;text-align: center;">
		        		
	        			<div style="width:100%;height:1px;border-bottom: 1px solid #e9eaec;margin:10px 0px;"></div>
	        		</Row >-->
	        		<Row style="height: 400px;overflow-y: scroll;padding: 10px;border: 1px solid #e9eaec;margin: 20px;">
	        			<div v-for="(item,key) in teacherList">
			        		<Row >
			        			<Col v-show="teacherList[key].length>0? true:false" span="4"  style="text-align: center;margin-bottom:10px;font-size: 16px;">
			        				{{key}}
			        			</Col>
			        		</Row >
			        		<Row >
			        			<div @click="choose" v-for="items in item">
			        				<Col span="6"  style="text-align: center;margin-bottom:10px;">
					        			<div tag="button" v-bind:class="[teacherselectshow.indexOf(items.value)>-1?activeclass:'']" :label="items.label" :value="items.value" style="cursor:pointer;margin: 0 auto;width: 80px;height: 38px;border:1px solid #e9eaec;line-height: 38px;border-radius: 5px;">
					        				{{items.label}}
					        			</div>
					        		</Col>
			        			</div>
				        		
			        		</Row >
			        	</div>
	        		</Row >
		       </Col>
			</Row >
		</div>
	</div>
</template>

<script>
	import { getsessionstorage } from '@/components/js/Localstorage'
	import api from "@/components/js/Apidomain.js"
	export default{
		data(){
			return{
				
				holdPostSelect:"",						//任职
				gradeSelect:"",							//年段
				subjectLeaderTypeSelect:"",				//科目长类型
				subjectSelect:"",						//科目
				departmentSelect:"",						//学部
				
				isGradeList: false,						//是否显示 年级选择列表
		        isSubjectLeaderTypeList: false,			//是否显示 科目长类型选择列表
		        isSubjectList: false,					// 是否显示 科目选择列表
		        isDepartmentList: false,				// 是否显示 学部选择列表
				
				holdPostList:[],
				gradeList: [ ], 				//年段选择列表
		        subjectLeaderTypeList: [ ], 	//科目长类型选择列表
		        subjectList: [ ], 				//科目选择列表
		        departmentList: [ ], 			//学部选择列表
		        
		        searchInfo:"",				//搜索的关键字
		        selections:"",				//表格的选择合集
		        //分页
		        recordCount:0,				//总条数
				current:1,					//页码
		        
		        //------------教师设置框里面
		        teacherSettingHidden:false,				//控制设置教师框的显示隐藏
		        teacherList:{
//		        	A:[{value: "7ef7a98fac4c48cd9795d031aaba8892", label: "安华"},{value: "7efdv98fac4c48cd9795d031aaba8892", label: "安华2"}],
//		        	B:[{value: "5658b629a1ae40fb98900909641b8842", label: "方艳斌"}]
		        },
		        teacherselect:[],							//根据条件请求服务器返回的老师数据
		        teacherselectshow:[],			//面板中的选中的颜色不一样的数据 "fe3e3cb22fa24852981f0dd1cacf0a54","df7cecdfae844a80ac8d94b11e246400"存这样的
		        settingroleselect:"",					//角色的选择 这个是id串
				settinggradeselect:"",					//年级选择
				settingsubjectselect:"",				//科目选择
				settingsubjectleadertypeselect:"",		//校级，年段级，学部级选择
				settingdepartmentselect:"",			//高中，初中部选择
				
				settinggradeselectshow:false,					//控制显示_年级选择
				settingsubjectselectshow:false,				//控制显示_科目选择
				settingsubjectleadertypeselectshow:false,		//控制显示_校级，年段级，学部级选择
				settingdepartmentselectshow:false,			//控制显示_高中，初中部选择
				
				settingrolelist:[],				//角色列表
				settingteacherlist:[],				//老师列表
				settinggradelist:[],				//年级列表	
				settingsubjectlist:[],				//科目列表
				settingsubjectleadertypelist:[],	//校级，年段级，学部级
				settingdepartmentlist:[],			//高中，初中部
		        
		        settingSearchInfo:"",				//搜索的关键字
		        
		        columns4: [
                    {type: 'selection',width: 60,align: 'center'},
                    {title: '工号',key: 'teacherNo',align: 'center',},
                    {title: '姓名',key: 'teacherName',align: 'center',},
                    {title: '账号',key: 'loginId',align: 'center',},
                    {title: '手机',key: 'phone',align: 'center',},
//                  {title: '任课科目',key: 'subject',align: 'center',},
                    {title: '职称',key: 'jobTitle',align: 'center',},
                    
                    
                ],
                data1: [
//                  {id:"4444",teacherNo:"122672013040",teacherName: '张三',subject: '语文',jobTitle: '初一'},
                ],
                
                loading: false,				//下载模板按钮上的加载中显示隐藏
			}
		},
		created(){
			this.getHoldPost()
//			this.getTeacherHoldPostInfo()
		},
		computed:{
			activeclass: function() {
				return 'active'
			},
		},
		methods:{
			choose:function(e){
				let dom = e.target;
				var domlabel = dom.getAttribute("label");
				var domvalue = dom.getAttribute("value");
//				console.log(dom.getAttribute("class"))
//				console.log(domvalue)
				//如果点到空白地方
				if(dom.getAttribute("label") == null){
					return;
				}
				if(dom.getAttribute("class") == "active" || dom.getAttribute("class") == "iconfont alicon-close_light"){
					for(let i = 0;i<this.teacherselect.length;i++){
						if(this.teacherselect[i].value == domvalue){
							this.teacherselect.splice(i,1)
//								//console.log(i)
						}
					}
					for(let i = 0;i<this.teacherselectshow.length;i++){
						if(this.teacherselectshow[i] == domvalue){
							this.teacherselectshow.splice(i,1)
//								//console.log(i)
						}
					}
				}else{
					this.teacherselect.push({value: domvalue,label: domlabel})
					this.teacherselectshow.push(domvalue)
				}
				
				
			},
			tableteacherselect:function(selection){
           		this.selections = selection
           	},
           	pageChange:function(value){
        		this.current = value;
        		this.getTeacherHoldPostInfo()
        	},
        	searchTeacher:function(){
        		var senddata = { 
           			"current":1,
					"pageSize":"10",
					"roleId": this.holdPostSelect,
					"gradeId": this.gradeSelect, 
					"subjectId": this.subjectSelect,
					"subjectLeaderType": this.subjectLeaderTypeSelect,
					"department": this.departmentSelect,
					"nameOrAccount": this.searchInfo
				}
           		var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getTeacherHoldPostInfo';
            	this.$http.post(url,senddata).then(function(response) {
					if(response.data.success == true){
						
//						console.log(response.data.data)
						self.data1 = response.data.data.items
						self.recordCount = response.data.data.recordCount
//						self.tableshow = false;
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
//		            		self.tableshow = false;
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00037',
							duration: 10,
							closable: true
						});
//						self.tableshow = false;
					});
        	},
//         	获取教师任职列表
           	getTeacherHoldPostInfo:function(){
//         		this.tableshow = true;
//				let sessionroleid = getsessionstorage('roleid');
           		var senddata = { 
           			"current":this.current,
					"pageSize":"10",
					"roleId": this.holdPostSelect,
					"gradeId": this.gradeSelect, 
					"subjectId": this.subjectSelect,
					"subjectLeaderType": this.subjectLeaderTypeSelect,
					"department": this.departmentSelect,
//					"nameOrAccount": "13145667988"
				}
           		var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getTeacherHoldPostInfo';
            	this.$http.post(url,senddata).then(function(response) {
					if(response.data.success == true){
						
//						console.log(response.data.data)
						self.data1 = response.data.data.items
						self.recordCount = response.data.data.recordCount
//						self.tableshow = false;
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
//		            		self.tableshow = false;
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00038',
							duration: 10,
							closable: true
						});
//						self.tableshow = false;
					});
           	},
			//任职改变选择触发函数
			holdPostChange:function(){
				this.current = 1;
				this.gradeSelect = "",							//年段
				this.subjectLeaderTypeSelect = "",				//科目长类型
				this.subjectSelect = "",						//科目
				this.departmentSelect = "",						//学部
				this.getSelectFromHoldPostByRole()
			},
			gradeChange:function(){
				this.current = 1;
				this.getTeacherHoldPostInfo()
			},
			subjectLeaderTypeChange:function(){
				this.current = 1;
				this.getSelectFromSubjectLeaderType()
//				this.getTeacherHoldPostInfo()
			},
			subjectChange:function(){
				this.current = 1;
				this.getTeacherHoldPostInfo()
			},
			departmentChange:function(){
				this.current = 1;
				this.getTeacherHoldPostInfo()
			},
			//根据科目长的角色去控制科目和学部的权限
			getSelectFromSubjectLeaderType:function(){
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getSelectFromSubjectLeaderType';
            	this.$http.post(url, {"subjectLeaderType": this.subjectLeaderTypeSelect}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						
						self.isGradeList = response.data.data.isGradeList							// 是否显示 科目选择列表
				        self.isDepartmentList = response.data.data.isDepartmentList							// 是否显示 学部选择列表
						self.getTeacherHoldPostInfo();
						
	            }else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
	            	}
	            	
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00039',
							duration: 10,
							closable: true
						});
				});
			},
			//获取任职列表
			getHoldPost:function(){
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getInitAllSelectFromTeacherHoldPost';
            	this.$http.post(url, {}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data.roleList)
						self.holdPostList = response.data.data.roleList
						self.getTeacherHoldPostInfo()
	           }else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
	            	}
	            	
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00040',
							duration: 10,
							closable: true
						});
				});
			},
			//根据职称获取其他下拉框
			getSelectFromHoldPostByRole:function(){
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getSelectFromHoldPostByRole';
            	this.$http.post(url, {"id": this.holdPostSelect}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						
						self.isGradeList = response.data.data.isGradeList									//是否显示 年级选择列表
				        self.isSubjectLeaderTypeList = response.data.data.isSubjectLeaderTypeList			//是否显示 科目长类型选择列表
				        self.isSubjectList = response.data.data.isSubjectList								// 是否显示 科目选择列表
				        self.isDepartmentList = response.data.data.isDepartmentList							// 是否显示 学部选择列表
						
						self.gradeList  = response.data.data.gradeList 										//年段选择列表
				        self.subjectLeaderTypeList = response.data.data.subjectLeaderTypeList 				//科目长类型选择列表
				        self.subjectList = response.data.data.subjectList 									//科目选择列表
				        self.departmentList = response.data.data.departmentList 							//学部选择列表
						
//						self.current = 1;
						self.getTeacherHoldPostInfo();
						
	           	}else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
	            	
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00041',
							duration: 10,
							closable: true
						});
				});
			},
			
			//勾选教师编辑部分
			editTeacher:function(){
				if(this.selections.length != 1){
					this.$Message.error({
								content: '请选择单条数据',
								duration: 10,
								closable: true
							});	
					return;
				}
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getEditInitAllSelectFromTeacherHoldPost';
            	this.$http.post(url, {"roleId": this.selections[0].roleId,"id":this.selections[0].id }).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						
						self.settinggradeselectshow = response.data.data.isGradeList									//是否显示 年级选择列表
				        self.settingsubjectleadertypeselectshow = response.data.data.isSubjectLeaderTypeList			//是否显示 科目长类型选择列表
				        self.settingsubjectselectshow = response.data.data.isSubjectList								// 是否显示 科目选择列表
				        self.settingdepartmentselectshow = response.data.data.isDepartmentList	
				        // 是否显示 学部选择列表
						self.settingrolelist = response.data.data.roleList
						self.settinggradelist  = response.data.data.gradeList 										//年段选择列表
				        self.settingsubjectleadertypelist = response.data.data.subjectLeaderTypeList 				//科目长类型选择列表
				        self.settingsubjectlist = response.data.data.subjectList 									//科目选择列表
				        self.settingdepartmentlist = response.data.data.departmentList 							//学部选择列表
						
						self.settingroleselect = response.data.data.selectRoleValue,					//角色的选择 这个是id串
						self.settinggradeselect = response.data.data.selectGradeValue,					//年级选择
						self.settingsubjectselect = response.data.data.selectSubjectValue,				//科目选择
						self.settingsubjectleadertypeselect = response.data.data.selectSubjectLeaderTypeValue,		//校级，年段级，学部级选择
						self.settingdepartmentselect = response.data.data.selectDepartmentValue,			//高中，初中部选择
						
						self.teacherselect = response.data.data.curTeacherList
						self.teacherselectshow = [];
           				var showdata = response.data.data.curTeacherList;
           				for(let i = 0;i<showdata.length;i++){
           					self.teacherselectshow.push(showdata[i].value)
           				}
						
						self.teacherList = response.data.data.pinyinResults
						self.teacherSettingHidden = true;
	           	}else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
	            	
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00042',
							duration: 10,
							closable: true
						});
				});
			},
			
			
			
			
			
			
			//································以下为老师设置框
			addTeacherAndCancel:function(){
				if(this.teacherSettingHidden == false){
					this.teacherHoldPost();
					this.teacherSettingHidden = true;
				}else{
					this.getTeacherHoldPostInfo();
					this.teacherSettingHidden = false;
					this.selections = [];
					this.settingroleselect = "";					//角色的选择 这个是id串
					this.settinggradeselect = "";					//年级选择
					this.settingsubjectselect = "";					//科目选择
					this.settingsubjectleadertypeselect = "";		//校级，年段级，学部级选择
					this.settingdepartmentselect = "";				//高中，初中部选择
				}
			},
			//获取教师选择列表A-Z
			teacherHoldPost:function(){
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getAddInitAllSelectFromTeacherHoldPost';
            	this.$http.post(url, {}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						self.teacherList = response.data.data.pinyinResults
						self.settingrolelist = response.data.data.roleList
						
	           }else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
	            	
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00043',
							duration: 10,
							closable: true
						});
				});
			},
			//根据职称获取其他下拉框
			getSelectFromHoldPostPopupBoxByRole:function(){
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getSelectFromHoldPostPopupBoxByRole';
            	this.$http.post(url, {"id": this.settingroleselect}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						
						self.settinggradeselectshow = response.data.data.isGradeList									//是否显示 年级选择列表
				        self.settingsubjectleadertypeselectshow = response.data.data.isSubjectLeaderTypeList			//是否显示 科目长类型选择列表
				        self.settingsubjectselectshow = response.data.data.isSubjectList								// 是否显示 科目选择列表
				        self.settingdepartmentselectshow = response.data.data.isDepartmentList							// 是否显示 学部选择列表
						
						self.settinggradelist  = response.data.data.gradeList 										//年段选择列表
				        self.settingsubjectleadertypelist = response.data.data.subjectLeaderTypeList 				//科目长类型选择列表
				        self.settingsubjectlist = response.data.data.subjectList 									//科目选择列表
				        self.settingdepartmentlist = response.data.data.departmentList 							//学部选择列表

						self.getteacher();
						
	           }else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
	            	
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00044',
							duration: 10,
							closable: true
						});
				});
			},
			//根据（科目长）获取其他下拉框
			getSelectFromPopupBoxSubjectLeaderType:function(){
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getSelectFromPopupBoxSubjectLeaderType';
            	this.$http.post(url, {"subjectLeaderType": this.settingsubjectleadertypeselect}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						
						self.settinggradeselectshow = response.data.data.isGradeList									//是否显示 年级选择列表
				        self.settingdepartmentselectshow = response.data.data.isDepartmentList							// 是否显示 学部选择列表
						
//						self.settinggradelist  = response.data.data.gradeList 										//年段选择列表
//				        self.settingsubjectleadertypelist = response.data.data.subjectLeaderTypeList 				//科目长类型选择列表
//				        self.settingsubjectlist = response.data.data.subjectList 									//科目选择列表
//				        self.settingdepartmentlist = response.data.data.departmentList 							//学部选择列表
//						
////						self.current = 1;
//						self.getTeacherHoldPostInfo();
						
	           }else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
	            	}
	            	
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00045',
							duration: 10,
							closable: true
						});
				});
			},
			//根据当前select框的选择获取老师
			getteacher:function(){
//				this.loading = true;
				var senddata = {
					"roleId": this.settingroleselect, 		//角色id
					"gradeId": this.settinggradeselect, 										//年级id
					"subjectId": this.settingsubjectselect,								//科目id
					"subjectLeaderType": this.settingsubjectleadertypeselect,							//科目长类型
					"department": this.settingdepartmentselect								//学部id
				}
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getCurTeacher';
            	this.$http.post(url, senddata).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						self.teacherselect = response.data.data
						self.teacherselectshow = [];
           				var showdata = response.data.data;
           				for(let i = 0;i<showdata.length;i++){
           					self.teacherselectshow.push(showdata[i].value)
           				}
	            }else if(response.data.success == false){
//	            		self.loading = false;
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
	            	
				})
				.catch(function(error) {
//					self.loading = false;
					self.$Message.error({
							content: '系统发生错误：错误码00046',
							duration: 10,
							closable: true
						});
				});
			},
			//角色改变触发函数
			settingroleselectchange:function(){
				this.getSelectFromHoldPostPopupBoxByRole()
			},
			//年级改变触发函数
			settinggradeselectchange:function(){
				this.getteacher()
			},
			//科目改变触发函数
			settingsubjectselectchange:function(){
				this.getteacher()
			},
			//科目长改变触发函数
			settingsubjectleadertypeselectchange:function(){
				this.getSelectFromPopupBoxSubjectLeaderType()
			},
			//学部改变触发函数
			settingdepartmentselectchange:function(){
				this.getteacher()
			},
			saveteacher:function(){
				var senddata = {
					"roleId": this.settingroleselect, 			//角色id
					"gradeId": this.settinggradeselect,			//年级id 
					"subjectId": this.settingsubjectselect,									//科目id
					"subjectLeaderType": this.settingsubjectleadertypeselect, 								//科目长类型
					"department": this.settingdepartmentselect,										//学部
					"teacherList":this.teacherselectshow
				}
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/saveHoldPostTeacher';
            	this.$http.post(url, senddata).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						self.$Message.success({
		                    content: response.data.msg,
		                    duration: 10,
		                    closable: true
               			})
	           		}else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
	            	}
				})
				.catch(function(error) {
					self.loading = false;
					self.$Message.error({
							content: '系统发生错误：错误码00047',
							duration: 10,
							closable: true
						});
				});
			},
			//设置老师里面的搜索框
			settingSearchTeacher:function(){
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getFilterTchTeacherFristPinyinList';
            	this.$http.post(url, {"nameOrAccount":this.settingSearchInfo}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						self.teacherList = response.data.data.pinyinResults
//						self.settingrolelist = response.data.data.roleList
						
	           	}else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
	            	}
	            	
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00048',
							duration: 10,
							closable: true
						});
				});
			},
			delteacher:function(){
           		let delallid = [];
           		for(let key in this.selections){
           			delallid.push({"roleId": this.selections[key].roleId,"id": this.selections[key].id})
           		}
           		if(delallid.length == 0){
           			this.$Message.error({
								content: '请勾选再删除',
								duration: 10,
								closable: true
							});	
           			return;
           		}
           		this.$Modal.confirm({
                    title: '确定删除',
                    content: '<p>确定删除这些老师信息吗</p>',
                    onOk: () => {
//		               this.tableshow = true;
		           		var self = this;
		            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/batchDeleteFromTeacherHoldPost';
		            	this.$http.post(url, {'idAndRoleId':delallid}).then(function(response) {
							if(response.data.success == true){
								self.$Message.success({
				                    content: '删除成功',
				                    duration: 10,
				                    closable: true
		               			})
		//						////console.log(response.data.data)
//								self.tableshow = false;
								self.getTeacherHoldPostInfo();
				            }else if(response.data.success == false){
				            		self.$Message.error({
										content: response.data.msg,
										duration: 10,
										closable: true
									});
//				            		self.tableshow = false;
				            	}
							})
							.catch(function(error) {
								self.$Message.error({
									content: '系统发生错误：错误码00049',
									duration: 10,
									closable: true
								});
//								self.tableshow = false;
							}); 
		                
                    },
                    onCancel: () => {
//                      this.$Message.info('Clicked cancel');
                    }
                });	
           	},
           	
           	
           	
           	exportexl:function(){
			
				var senddata = { 
					"roleId": this.holdPostSelect,
					"gradeId": this.gradeSelect, 
					"subjectId": this.subjectSelect,
					"subjectLeaderType": this.subjectLeaderTypeSelect,
					"department": this.departmentSelect,
				}
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/exportFromTeacherHoldPostExcel';
            	this.$http.post(url,senddata).then(function(response) {
					if(response.data.success == true){
//						////console.log(response.data.data)
						window.location.href = response.data.data;
						self.loading = false;
	            }else if(response.data.success == false){
	            		self.loading = false;
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
	            	}
	            	
				})
				.catch(function(error) {
					self.loading = false;
					self.$Message.error({
							content: '系统发生错误：错误码00050',
							duration: 10,
							closable: true
						});
				});
				
			}  
			
			
		},
		watch:{
			searchInfo:function(){
				this.searchTeacher();
			},
			settingSearchInfo:function(){
				this.settingSearchTeacher();
			}
		}
	}
</script>

<style>
	.active{
		background-color: #517edb;
		color: white;
	}
</style>